class Solution {
public:
    bool mergeTriplets(vector<vector<int>>& triplets, vector<int>& target) {
        int m = triplets.size();
        vector<vector<int>> keymap(3, vector<int>());
        int k1, k2, k3;
        for (int i = 0; i < m; i++){
            
            k1 = triplets[i][0], k2 = triplets[i][1], k3 = triplets[i][2];
            if(k1 == target[0] && k2 <= target[1] && k3 <= target[2]) {
                keymap[0].push_back(i);
            }
            if(k2 == target[1] && k1 <= target[0] && k3 <= target[2]) {
                keymap[1].push_back(i);
            }
            if(k3 == target[2] && k1 <= target[0] && k2 <= target[1]) {
                keymap[2].push_back(i);
            }

            if(keymap[0].size() && keymap[1].size() && keymap[2].size()){
                return true;
            }
        }
        return false;
    }
};

class Solution {
public:
    int maximumRemovals(string s, string p, vector<int>& removable) {
        int max_k = removable.size();
        if(max_k == 0) return 0;
        int k = 0, min_idex=0;
        int temp_s;

        for(int i = 0; i < max_k; i++){
            
            // for(int n = i+1; n < removable.size(); n++){
            //     if(removable[n] > removable[i]) removable[n]--;
            // }
            sort(removable.begin(), removable.begin()+1+i);
            temp_s = s;
            for(int n=0; n<i+1; n++){
                temp_s.erase(temp_s.begin()+removable[n]);
            }

            for(int j=0; j<p.size(); ){
                
                for(int m=0; m<temp_s.size(); m++){
                    
                    for(int n=0; n<i+1; i++){
                        if(j == removable[n]) j++;
                    }

                    if(p[j] == temp_s[m]) j++; 
                    if(j == p.size()) break;
                }
                
                if(j >= p.size()) k = i+1;
                break;
            }
            if(k != i+1) break;
        }
        return k;

    }
};


class Solution {
public:
    bool makeEqual(vector<string>& words) {
        int n = words.size();
        if(n == 1) return true;

        vector<int> char_map(26, 0);

        int total_length = 0;
        for(int i = 0; i < n; i++){
            total_length+= words[i].size();
            for(int j = 0; j < words[i].size(); j++){
                char_map[words[i][j]-'a']++;
            }
        }
        if(total_length % n != 0) return false;
        int avg_size = total_length/n;
        for(int i = 0; i < char_map.size(); i++){
            if(char_map[i]%n != 0) return false;
        }
        
        return true;
    }
};